[C#] LINQ Group By


Feb 10, 2023

In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

Scrapy 和 Redis 分散式crawlers (蘋果日報為例)

Scrapy 和 Redis 分散式crawlers (蘋果日報為例)

[論文筆記] Seeing Out of tHe bOx - End-to-End Pre-training for Vision-Language Representation Learning

[論文筆記] Seeing Out of tHe bOx - End-to-End Pre-training for Vision-Language Representation Learning

程式基礎 —— Javascript

程式基礎 —— Javascript






留言討論






2
2
2